package com.dgh.school.service.impl;

import com.dgh.school.bean.Maillist;
import com.dgh.school.common.R;
import com.dgh.school.mapper.MaillistMapper;
import com.dgh.school.service.MaillstServuce;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MaillistServiceImpl implements MaillstServuce {
    @Autowired
    private MaillistMapper maillistMapper;
    @Override
    public List<Maillist> selectAll() {

        List<Maillist> maillists = maillistMapper.selectAll();
        return maillists;
    }

    @Override
    public R selectByPage(int pageNum, int pageSize) throws Exception {

        PageHelper.startPage(pageNum, pageSize);
        // 查询全部数据
        List<Maillist> maillists = maillistMapper.selectAll();
        // 借助分页助手，获得分页信息
        PageInfo<Maillist> pageInfo = new PageInfo<>(maillists);

        return R.ok().setDate("pageInfo", pageInfo);
    }
}
